<?php
require_once ("includes/table-admin.php");

class Table_admin_user extends Table_admin{

function Table_admin_user(){
	$this->Table_admin("Tên người dùng","users");
}

function mysql_string(){
	return 'SELECT * FROM user ORDER BY username ASC';
}

function a_row($num_row,$num_item,$data){
	$html_row = <<<HTML
	<tr class="%s">
        <td%s>%s</td>
        <td class="left">%s</td>
        <td><a href="admin.php?view=users&page=%s&id=%s">Xem</a></td>
        <td><a href="action.php?do=del_user&id=%s">Xóa</a></td>
    </tr>
HTML;

	$html_row_expand = <<<HTML
    <tr id="row-expand" class="%s">
        <td class="left" colspan="3">Email: %s</td>
    </tr>
HTML;

	$class = 'row'.($num_row%2+1);	
	$html = sprintf($html_row,$class,'%s',$num_item,$data['username'],$_SESSION['page'],$data['user_id'],$data['user_id']);

	if ($_SESSION['id']==$data['user_id']){
		$html = sprintf($html,' rowspan="2"');
		$html .= sprintf($html_row_expand,$class,$data['email']);
	} else {
		$html = sprintf($html,'');	
	}
	
	return $html;
}
}

if (!check_permission('admin')){return;}
$_table_admin_user = new Table_admin_user();
$_table_admin_user->html();

?>